package com.sjsu.aws.primitive.client.service;

import com.sjsu.aws.primitve.Primitive;
import com.sjsu.aws.primitve.PrimitiveServiceImpl;

public class CreatePrimitiveServices {
	
	public void rendezvousService() throws Exception {
		// group table
		Primitive pm = new Primitive();
		pm.setServiceName("Rendezvous");
		pm.setKeyName("uuId");
		pm.setKeyType("S");
		PrimitiveServiceImpl primitiveServiceImpl = new PrimitiveServiceImpl();
		primitiveServiceImpl.createService(pm);
		
	}
	
	public void createGroupMembershipService() throws Exception {
		// group table
		Primitive pm = new Primitive();
		pm.setServiceName("Group");
		pm.setKeyName("uuId");
		pm.setKeyType("S");
		PrimitiveServiceImpl primitiveServiceImpl = new PrimitiveServiceImpl();
		primitiveServiceImpl.createService(pm);
		
	}
	
	public void createConfigMgmtService() throws Exception {
		// config mgmt table
		Primitive pm = new Primitive();
		pm.setServiceName("ConfigurationMgmt");
		pm.setKeyName("configId");
		pm.setKeyType("S");
		PrimitiveServiceImpl primitiveServiceImpl = new PrimitiveServiceImpl();
		primitiveServiceImpl.createService(pm);
		
	}
	
	public void createWatcherRegistrationService() throws Exception {
		// config mgmt table
		Primitive pm = new Primitive();
		pm.setServiceName("WatchRegister");
		pm.setKeyName("watcherName");
		pm.setKeyType("S");
		PrimitiveServiceImpl primitiveServiceImpl = new PrimitiveServiceImpl();
		primitiveServiceImpl.createService(pm);
		
	}
	
	public void doubleBarrierService() throws Exception {
		// double barrier table
		Primitive pm = new Primitive();
		pm.setServiceName("DoubleBarrier");
		pm.setKeyName("uuId");
		pm.setKeyType("S");
		PrimitiveServiceImpl primitiveServiceImpl = new PrimitiveServiceImpl();
		primitiveServiceImpl.createService(pm);
	}
	
	public static void main(String[] args) {
		CreatePrimitiveServices createPrimitiveServices = new CreatePrimitiveServices();
		try {
	        createPrimitiveServices.rendezvousService();
	        createPrimitiveServices.createGroupMembershipService();
	        createPrimitiveServices.createConfigMgmtService();
	        createPrimitiveServices.createWatcherRegistrationService();
	        createPrimitiveServices.doubleBarrierService();
        } catch (Exception e) {
        	System.out.println("Error in creating Services "+e.getMessage());       
	        e.printStackTrace();
        }
		
    }
}
